package cn.wolfcode.wolf2w.service.impl;

import cn.wolfcode.wolf2w.domain.Spot;
import cn.wolfcode.wolf2w.repository.SpotRepository;
import cn.wolfcode.wolf2w.service.ISpotService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class SpotServiceImpl implements ISpotService {

    @Autowired
    private SpotRepository spotRepository;
    @Autowired
    private MongoTemplate template;
    
    @Autowired
    private  ISpotService spotService;



    @Override
    public void save(Spot spot) {
        spot.setId(null);
        spotRepository.save(spot);
    }

    @Override
    public void update(Spot spot) {
        spotRepository.save(spot);
    }

    @Override
    public void delete(String id) {
        spotRepository.deleteById(id);
    }

    @Override
    public Spot get(String id) {
        return spotRepository.findById(id).orElse(null);
    }

    @Override
    public List<Spot> list() {
        return spotRepository.findAll();
    }


}
